set(SHM_LIB shm_lib)

add_library(${SHM_LIB}-deps INTERFACE)
target_include_directories(${SHM_LIB}-deps INTERFACE inc)

add_library(${SHM_LIB}-object OBJECT
    src/shm.c
)
target_link_libraries(${SHM_LIB}-object PRIVATE ${SHM_LIB}-deps)

if(BUILD_SHARED_LIBS)
    add_library(${SHM_LIB} SHARED $<TARGET_OBJECTS:${SHM_LIB}-object>)
else()
    add_library(${SHM_LIB} STATIC $<TARGET_OBJECTS:${SHM_LIB}-object>)
endif()
target_link_libraries(${SHM_LIB} INTERFACE ${SHM_LIB}-deps) # for other module
set_property(TARGET ${SHM_LIB} PROPERTY OUTPUT_NAME "${SHM_LIB}")
set_property(TARGET ${SHM_LIB} PROPERTY VERSION 0.0.1)
set_property(TARGET ${SHM_LIB} PROPERTY SOVERSION 0)

if(WIN32)
    set_property(TARGET ${SHM_LIB} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR})
    set_property(TARGET ${SHM_LIB} PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR})
endif()

install(TARGETS ${SHM_LIB} DESTINATION lib)
install(DIRECTORY inc/ DESTINATION include/${SHM_LIB})